﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Audio;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VRB_0._1
{
    class MenuScreen
    {
        protected enum MenuChoice
        {
            SELECT_MAP = 1, OPTIONS = 2, EXIT = 3
        }

        protected SpriteFont menuFont;
        protected MenuChoice currentChoice;
        protected Texture2D selector;
        protected Texture2D background;

        protected SoundEffect select;
        protected SoundEffect back;
        protected SoundEffect choose;

        public void Initialize(ContentManager Content)
        {
            menuFont = Content.Load<SpriteFont>("gameFont");
            selector = Content.Load<Texture2D>("selector");
            background = Content.Load<Texture2D>("meny");

            select = Content.Load<SoundEffect>("select");
            back = Content.Load<SoundEffect>("back");
            choose = Content.Load<SoundEffect>("choice");

            currentChoice = MenuChoice.SELECT_MAP;
        }

        public void Draw(SpriteBatch spriteBatch, Viewport Viewport)
        {
            spriteBatch.Draw(background, Vector2.Zero, Color.White);
            spriteBatch.DrawString(menuFont, "Select Map",
                        new Vector2(Viewport.TitleSafeArea.X + 50, Viewport.TitleSafeArea.Y + 200), Color.White);
            spriteBatch.DrawString(menuFont, "Options",
                        new Vector2(Viewport.TitleSafeArea.X + 50, Viewport.TitleSafeArea.Y + 250), Color.White);
            spriteBatch.DrawString(menuFont, "Exit Game",
                        new Vector2(Viewport.TitleSafeArea.X + 50, Viewport.TitleSafeArea.Y + 300), Color.White);
            spriteBatch.Draw(selector, new Vector2(Viewport.TitleSafeArea.X + 15, Viewport.TitleSafeArea.Y + 155 + 50 * (int)currentChoice), Color.White);
        }

        public void InputUp()
        {
            if ((int)currentChoice != 1)
            {
                choose.Play();
                currentChoice--;
            }
        }
        public void InputDown()
        {
            if ((int)currentChoice != 3)
            {
                choose.Play();
                currentChoice++;
            }
        }
        public Game1.GameState InputSelect()
        {
            switch (currentChoice)
            {
                case MenuChoice.SELECT_MAP:
                    select.Play();
                    return Game1.GameState.MAPSELECT;
                case MenuChoice.OPTIONS:
                    select.Play();
                    return Game1.GameState.OPTIONS;
                case MenuChoice.EXIT:
                    select.Play();
                    return Game1.GameState.EXIT;
                default:
                    return Game1.GameState.MAINMENU;
            }
        }
    }
}
